package com.happok.onlineclass.usermanagement.setting.controller;

import com.happok.onlineclass.usermanagement.setting.dto.*;
import com.happok.onlineclass.usermanagement.setting.service.SettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 验证码设置
 * 包括功能设置、服务器配置等等
 *
 * @author : chenac
 * @module 在线课堂/用户管理
 * @date : 2021/10/8 14:24
 */
@RestController
@Api(tags = "验证码设置")
@RequestMapping(value = "/user-management")
public class SettingController {

    @Autowired
    private SettingService settingService;

    /**
     * 查询各功能可用状态
     *
     * @param
     * @author: chenac
     * @date: 15:02
     * @execption:
     * @return: java.util.List<com.happok.onlineclass.usermanagement.setting.dto.FunctionStatus>
     */
    @GetMapping(value = "/verify-code/setting/function/status/v1")
    @ApiOperation(value = "查询各功能状态")
    public List<FunctionStatusDTO> getFunctionStatus() {
        return settingService.getFunctionStatus();
    }

    /**
     * 修改邮箱设置
     * 阿里云输入账户密码，163邮箱输入账号授权码<br>
     * 20000,修改邮箱设置成功<br>
     * 40000,参数异常<br>
     * 40500,邮箱服务设置异常<br>
     * 42101,邮箱服务器连接异常<br>
     * 50000,服务端异常
     *
     * @param emailSetting
     * @author: chenac
     * @date: 16:39
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/email/v1")
    @ApiOperation(value = "修改邮箱设置")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "修改邮箱设置成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "邮箱服务设置异常"),
            @ApiResponse(code = 42101, message = "邮箱服务器连接异常"),
            @ApiResponse(code = 50000, message = "服务端异常"),
    })
    public void updateEmailSetting(@RequestBody @Valid EmailSettingDTO emailSetting) {
        settingService.updateEmailSetting(emailSetting);
    }

    /**
     * 查询邮箱设置
     *
     * @param
     * @author: chenac
     * @date: 16:44
     * @execption:
     * @return: com.happok.onlineclass.usermanagement.setting.dto.EmailSettingInfoDTO
     */
    @GetMapping(value = "/email/v1")
    @ApiOperation(value = "查询邮箱设置")
    public EmailSettingInfoDTO getEmailSetting() {
        return settingService.getEmailSetting(true);
    }

    /**
     * 修改短信设置
     * 20000,修改短信设置成功<br>
     * 40000,参数异常<br>
     * 42102,短信服务器连接异常<br>
     * 40500,短信平台设置异常<br>
     * 50000,服务端异常
     *
     * @param smsSetting
     * @author: chenac
     * @date: 16:54
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/sms/v1")
    @ApiOperation(value = "修改短信设置")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "修改短信设置成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "短信平台设置异常"),
            @ApiResponse(code = 42102, message = "短信服务器连接异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void updateSmsSetting(@RequestBody @Valid SmsSettingDTO smsSetting) {
        settingService.updateSmsSetting(smsSetting);
    }

    /**
     * 查询短信设置
     *
     * @param
     * @author: chenac
     * @date: 16:58
     * @execption:
     * @return: com.happok.onlineclass.usermanagement.setting.dto.SmsSettingInfoDTO
     */
    @GetMapping(value = "/sms/v1")
    @ApiOperation(value = "查询短信设置")
    public List<SmsSettingInfoDTO> listSmsSetting() {
        return settingService.listSmsSetting();
    }

    /**
     * 短信平台禁启用
     * 20000,短信平台禁启用成功<br>
     * 40000,参数异常<br>
     * 42102,短信服务器连接异常<br>
     * 50000,服务端异常
     *
     * @param smsEnable
     * @author: chenac
     * @date: 17:19
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/sms/status/v1")
    @ApiOperation(value = "短信平台禁启用")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "短信平台禁启用成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 42102, message = "短信服务器连接异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void smsEnable(@RequestBody @Valid SmsEnableDTO smsEnable) {
        settingService.smsEnable(smsEnable);
    }

    /**
     * 开启或关闭用户注册
     * 20000,开启或关闭用户注册成功<br>
     * 40000,参数异常<br>
     * 40500,设置异常<br>
     * 50000,服务端异常
     *
     * @param userRegisterStatusDTO
     * @author: chenac
     * @date: 17:36
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/verify-code/setting/user-regist/status/v1")
    @ApiOperation(value = "开启或关闭用户注册")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "开启或关闭用户注册成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "设置异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void openOrCloseUserRegister(@RequestBody @Valid UserRegisterStatusDTO userRegisterStatusDTO) {
        settingService.openOrCloseUserRegister(userRegisterStatusDTO);
    }

    /**
     * 修改用户注册验证
     * 20000,修改用户注册验证成功<br>
     * 40000,参数异常<br>
     * 40500,设置异常<br>
     * 50000,服务端异常
     *
     * @param updateVerify
     * @author: chenac
     * @date: 17:56
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/verify-code/setting/user-regist/v1")
    @ApiOperation(value = "修改用户注册验证")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "修改用户注册验证成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "设置异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void updateUserRegister(@RequestBody @Valid UpdateVerifyDTO updateVerify) {
        settingService.updateUserRegister(updateVerify);
    }

    /**
     * 查询用户注册验证
     *
     * @param
     * @author: chenac
     * @date: 18:02
     * @execption:
     * @return: com.happok.onlineclass.usermanagement.setting.dto.UpdateUserRegisterDTO
     */
    @GetMapping(value = "/verify-code/setting/user-regist/v1")
    @ApiOperation(value = "查询用户注册验证")
    public FunctionVerifyDTO getUserRegister() {
        return settingService.getUserRegister();
    }

    /**
     * 修改用户登录验证
     * 20000,修改用户登录验证成功<br>
     * 40000,参数异常<br>
     * 40500,设置异常<br>
     * 50000,服务端异常
     *
     * @param updateVerify
     * @author: chenac
     * @date: 9:24
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/verify-code/setting/user-login/v1")
    @ApiOperation(value = "修改用户登录验证")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "修改用户登录验证成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "设置异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void updateUserLogin(@RequestBody @Valid UpdateVerifyDTO updateVerify) {
        settingService.updateUserLogin(updateVerify);
    }

    /**
     * 查询用户登录验证
     *
     * @param
     * @author: chenac
     * @date: 9:25
     * @execption:
     * @return: com.happok.onlineclass.usermanagement.setting.dto.UpdateVerifyDTO
     */
    @GetMapping(value = "/verify-code/setting/user-login/v1")
    @ApiOperation(value = "查询用户登录验证")
    public FunctionVerifyDTO getUserLogin() {
        return settingService.getUserLogin();
    }

    /**
     * 修改忘记密码验证
     * 20000,修改忘记密码验证成功<br>
     * 40000,参数异常<br>
     * 40500,设置异常<br>
     * 50000,服务端异常
     *
     * @param updateVerify
     * @author: chenac
     * @date: 9:27
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/verify-code/setting/forget-password/v1")
    @ApiOperation(value = "修改忘记密码验证")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "修改忘记密码验证成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "设置异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void updateForgetPwd(@RequestBody @Valid UpdateVerifyDTO updateVerify) {
        settingService.updateForgetPwd(updateVerify);
    }

    /**
     * 查询忘记密码验证
     *
     * @param
     * @author: chenac
     * @date: 9:28
     * @execption:
     * @return: com.happok.onlineclass.usermanagement.setting.dto.UpdateVerifyDTO
     */
    @GetMapping(value = "/verify-code/setting/forget-password/v1")
    @ApiOperation(value = "查询忘记密码验证")
    public FunctionVerifyDTO getForgetPwd() {
        return settingService.getForgetPwd();
    }

    /**
     * 修改重置密码验证
     * 20000,修改重置密码验证成功<br>
     * 40000,参数异常<br>
     * 40500,设置异常<br>
     * 50000,服务端异常
     *
     * @param updateVerify
     * @author: chenac
     * @date: 9:30
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/verify-code/setting/reset-password/v1")
    @ApiOperation(value = "修改重置密码验证")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "修改重置密码验证成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "设置异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void updateResetPwd(@RequestBody @Valid UpdateVerifyDTO updateVerify) {
        settingService.updateResetPwd(updateVerify);
    }

    /**
     * 查询重置密码验证
     *
     * @param
     * @author: chenac
     * @date: 9:31
     * @execption:
     * @return: com.happok.onlineclass.usermanagement.setting.dto.UpdateVerifyDTO
     */
    @GetMapping(value = "/verify-code/setting/reset-password/v1")
    @ApiOperation(value = "查询重置密码验证")
    public FunctionVerifyDTO getResetPwd() {
        return settingService.getResetPwd();
    }

    /**
     * 修改手机号或邮箱验证
     * 20000,修改手机号或邮箱验证成功<br>
     * 40000,参数异常<br>
     * 40500,设置异常<br>
     * 50000,服务端异常
     *
     * @param updateVerify
     * @author: chenac
     * @date: 9:32
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/verify-code/setting/modify-account/v1")
    @ApiOperation(value = "修改手机号或邮箱验证")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "修改手机号或邮箱验证成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "设置异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void updateModifyAccount(@RequestBody @Valid UpdateVerifyDTO updateVerify) {
        settingService.updateModifyAccount(updateVerify);
    }

    /**
     * 查询手机号或邮箱验证
     *
     * @param
     * @author: chenac
     * @date: 9:32
     * @execption:
     * @return: com.happok.onlineclass.usermanagement.setting.dto.UpdateVerifyDTO
     */
    @GetMapping(value = "/verify-code/setting/modify-account/v1")
    @ApiOperation(value = "查询手机号或邮箱验证")
    public FunctionVerifyDTO getModifyAccount() {
        return settingService.getModifyAccount();
    }

    /**
     * 修改平台添加用户验证
     * 20000,修改平台添加用户验证成功<br>
     * 40000,参数异常<br>
     * 40500,设置异常<br>
     * 50000,服务端异常
     *
     * @param updateVerify
     * @author: chenac
     * @date: 9:33
     * @execption:
     * @return: void
     */
    @PutMapping(value = "/verify-code/setting/add-user/v1")
    @ApiOperation(value = "修改平台添加用户验证")
    @ApiResponses({
            @ApiResponse(code = 20000, message = "修改平台添加用户验证成功"),
            @ApiResponse(code = 40000, message = "参数异常"),
            @ApiResponse(code = 40500, message = "设置异常"),
            @ApiResponse(code = 50000, message = "服务端异常")
    })
    public void updateAddUser(@RequestBody @Valid UpdateVerifyDTO updateVerify) {
        settingService.updateAddUser(updateVerify);
    }

    /**
     * 查询平台添加用户验证
     *
     * @param
     * @author: chenac
     * @date:  9:34
     * @execption:
     * @return: com.happok.onlineclass.usermanagement.setting.dto.UpdateVerifyDTO
     */
    @GetMapping(value = "/verify-code/setting/add-user/v1")
    @ApiOperation(value = "查询平台添加用户验证")
    public FunctionVerifyDTO getAddUser() {
        return settingService.getAddUser();
    }
}